//
// Created by Zhangwj on 2023/9/25.
//

#include "Parser.h"

Parser::Parser(std::vector<std::tuple<LexType, std::string>> tokens_) : tokens(std::move(tokens_)) {
    pos = 0;
}

void Parser::next() {
    if (pos < tokens.size() - 1) {
        pos++;
    }
}

LexType Parser::getLexType(int i) { // get tokens[pos + i]
    if (pos + i < tokens.size()) {
        return std::get<0>(tokens.at(pos + i));
    } else {
        return LexType::LEXER_END;
    }
}

std::string Parser::getString(int i) {
    if (pos + i < tokens.size()) {
        return std::get<1>(tokens.at(pos + i));
    } else {
        return "";
    }
}
